<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui">

<h:head>

</h:head>
<h:body>
	<h:form id="frmCadConta">
		<br />
		<h3 style="margin-top: 0">CADASTRO DE CONTA</h3>
		<div align="left">

			<p:commandButton value="Novo" actionListener="#{contaBean.novo}"
				disabled="#{contaBean.novo}" ajax="frmCadConta" update="listaCFilha" />

			<p:commandButton value="Salvar" actionListener="#{contaBean.gravar}"
				update="frmCadConta" disabled="#{contaBean.desabilitarGravar}" />

			<p:commandButton value="Editar" actionListener="#{contaBean.editar}"
				update="frmCadConta" disabled="#{contaBean.alterar}" />

			<p:commandButton value="Consulta" type="button"
				onclick="PF('consulta').show();" disabled="consulta" />

			<p:commandButton value="Cancelar" disabled="#{contaBean.cancelar}"
				actionListener="#{contaBean.novo}" />

			<p:messages id="messages" showDetail="true" autoUpdate="true"
				closable="true" />

			<p:dialog header="Consulta" widgetVar="consulta" modal="true"
				height="300" width="500">
				<h:panelGrid columns="2">
					<p:inputText value="#{contaBean.descricaoPesquisa}" />

					<p:commandButton value="Pesquisar"
						actionListener="#{contaBean.pesquisaConta}" update="pesquisaConta" />
				</h:panelGrid>


				<p:dataTable id="pesquisaConta" paginator="true" rows="6"
					value="#{contaBean.listaConta}" var="contas">

					<p:column headerText="Codigo">
						<h:outputText value="#{contas.idConta}" />
					</p:column>

					<p:column headerText="Descrição">
						<h:outputText value="#{contas.descricao}" />
					</p:column>

					<p:column headerText="Desmembrada">
						<h:outputText value="#{contas.desmembrada}" />
					</p:column>

					<p:column headerText="Inativa">
						<h:outputText value="#{contas.inativa}" />
					</p:column>

					<p:column headerText="Selecionar">
						<p:commandLink id="link" value="Selecionar"
							ajax="dialog,frmCadConta" action="#{contaBean.selecionar}"
							update="listaCFilha">
							<f:setPropertyActionListener value="#{contas.idConta}"
								target="#{contaBean.id}" />
						</p:commandLink>
					</p:column>

				</p:dataTable>

			</p:dialog>



			<p:tabView style="border: 0px">

				<p:tab id="dadosConta" title="Cadastro">
					<h:panelGrid columns="4">
					Desmembrada:
						<p:selectBooleanCheckbox value="#{contaBean.conta.desmembrada}" />
					
					Inativa:
						<p:selectBooleanCheckbox value="#{contaBean.conta.inativa}" />
					</h:panelGrid>
					<h:panelGrid columns="2" columnClasses="label, value">
					
					Codigo:
					<p:inputText id="contaCodigo" value="#{contaBean.conta.idConta}"
							disabled="true" />
					
					Descrição:
					<p:inputText id="contaDesc" value="#{contaBean.conta.descricao}" />

					</h:panelGrid>
					<br />
					<br />
					<p:commandButton value="Cadastro Conta Filha" type="button"
						id="cadContaFilha" onclick="PF('cadFilhaConta').show();"
						disabled="#{contaBean.cadastroContaFilha}" />

					<p:dialog header="Cadastro Conta Filha" widgetVar="cadFilhaConta"
						modal="true" height="100" width="300">
						<h:panelGrid columns="2">
						Codigo:
						 <p:inputText value="#{contaBean.contaFilha.idContaFilha}"
								disabled="true" />
				 
						Descrição:
						<p:inputText value="#{contaBean.contaFilha.descricao}" />

							<p:commandButton value="Salvar"
								actionListener="#{contaBean.salvarContaFilha}"
								update="listaCFilha" ajax="dialog" />

						</h:panelGrid>

					</p:dialog>

					<h:panelGrid id="dadosCFilha">
						<p:dataTable id="listaCFilha" value="#{contaBean.listaContaFilha}"
							paginator="true" rows="6" var="contaFilha">

							<p:column headerText="Codigo">
								<h:outputLabel value="#{contaFilha.idContaFilha}" />
							</p:column>

							<p:column headerText="Descrição">
								<h:outputLabel value="#{contaFilha.descricao}" />
							</p:column>


							<p:column headerText="Excluir">
								<p:commandLink id="excluirContaFilha" value="Excluir"
									ajax="dialog" action="#{contaBean.excluirContaFilha}"
									update="listaCFilha">
									<f:setPropertyActionListener value="#{contaFilha.idContaFilha}"
										target="#{contaBean.idContaFilha}" />
								</p:commandLink>
							</p:column>

						</p:dataTable>

					</h:panelGrid>

				</p:tab>


			</p:tabView>
		</div>
	</h:form>
</h:body>
</html>